home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #9 / Amiga Plus CD - 2004 - No. 09.iso / amigaplus / tools / dev_libs / feelin040718 / demos / string.c < prev    next >
C/C++ Source or Header  |  2004-08-03  |  8KB  |  205 lines

  1. ;/*
  2.    F_Create.rexx EXE String
  3.    QUIT
  4.    _________________________________________________________________________
  5.  
  6.    Written by Olivier LAVIALE <HaploLaMain@aol.com>
  7.  
  8.    This demo shows how to use and customise FC_String objects.
  9. */
  10.  
  11. ///Header
  12.  
  13. #include <libraries/feelin.h>
  14.  
  15. #include <proto/exec.h>
  16. #include <proto/dos.h>
  17. #include <proto/graphics.h>
  18. #include <proto/feelin.h>
  19.  
  20. struct FeelinBase                  *FeelinBase;
  21. #define GfxBase                     FeelinBase -> Graphics
  22.  
  23. ///drawstri
  24. SAVEDS void drawstri(struct RastPort *rp,struct FeelinRect *rect,ULONG a,ULONG b)
  25. {
  26.    WORD  x1 = rect -> x1,
  27.          x3 = rect -> x2,
  28.          x2 = (x3 - x1) / 3 + x1,
  29.          y1 = rect -> y1,
  30.          y2 = rect -> y2;
  31.  
  32.    static UWORD pt[] = {0xFF00,0x7F80,0x3FC0,0x1FE0,
  33.                         0x0FF0,0x07F8,0x03FC,0x01FE,
  34.                         0x00FF,0x807F,0xC03F,0xE01F,
  35.                         0xF00F,0xF807,0xFC03,0xFE01};
  36.  
  37.    _APen(a);
  38.    _BPen(b);
  39.    rp -> AreaPtrn = pt;
  40.    rp -> AreaPtSz = 4;
  41.    _Boxf(x2+1,y1,x3,y2);
  42.    rp -> AreaPtSz = 0;
  43.    rp -> AreaPtrn = NULL;
  44.  
  45.    _APen(b);
  46.    _Boxf(x1,y1,x2,y2);
  47. }
  48. //+
  49. ///drawback
  50. F_HOOKM(void,drawback,FS_ImageDisplay_HookDraw)
  51. {
  52.    drawstri(Msg -> Render -> RPort,Msg -> Region,Msg -> Render -> Palette -> Pens[FV_Pen_Fill],Msg -> Render -> Palette -> Pens[FV_Pen_HalfShadow]);
  53. }
  54. //+
  55. ///drawcursor
  56. F_HOOKM(void,drawcursor,FS_ImageDisplay_HookDraw)
  57. {
  58.    struct RastPort  *rp = Msg -> Render -> RPort;
  59.    WORD              x1 = Msg -> Rect -> x1,
  60.                      x2 = Msg -> Rect -> x2,
  61.                      y1 = Msg -> Rect -> y1,
  62.                      y2 = Msg -> Rect -> y2;
  63.    ULONG             ap = Msg -> Render -> Palette -> Pens[FV_Pen_Shine],
  64.                      bp = Msg -> Render -> Palette -> Pens[FV_Pen_Shadow],
  65.                      cp = Msg -> Render -> Palette -> Pens[FV_Pen_HalfShine];
  66.  
  67.    drawstri(rp,Msg -> Region,ap,cp);
  68.  
  69.    _APen(ap); _Move(x1+1,y2); _Draw(x2,y2); _Draw(x2,y1+1);
  70.    _APen(bp); _Move(x1,y2-1); _Draw(x1,y1); _Draw(x2-1,y1);
  71. }
  72. //+
  73. ///drawcursor2
  74. F_HOOKM(void,drawcursor2,FS_ImageDisplay_HookDraw)
  75. {
  76.    drawstri(Msg -> Render -> RPort,Msg -> Region,Msg -> Render -> Palette -> Pens[FV_Pen_Shine],Msg -> Render -> Palette -> Pens[FV_Pen_HalfShine]);
  77. }
  78. //+
  79. ///drawblink
  80. F_HOOKM(void,drawblink,FS_ImageDisplay_HookDraw)
  81. {
  82.    struct RastPort  *rp = Msg -> Render -> RPort;
  83.    WORD              x1 = Msg -> Rect -> x1,
  84.                      x2 = Msg -> Rect -> x2,
  85.                      y1 = Msg -> Rect -> y1,
  86.                      y2 = Msg -> Rect -> y2;
  87.    ULONG             ap = Msg -> Render -> Palette -> Pens[FV_Pen_HalfShine],
  88.                      bp = Msg -> Render -> Palette -> Pens[FV_Pen_HalfDark],
  89.                      cp = Msg -> Render -> Palette -> Pens[FV_Pen_Fill];
  90.  
  91.    drawstri(rp,Msg -> Region,ap,cp);
  92.  
  93.    _APen(ap); _Move(x1+1,y2); _Draw(x2,y2); _Draw(x2,y1+1);
  94.    _APen(bp); _Move(x1,y2-1); _Draw(x1,y1); _Draw(x2-1,y1);
  95. }
  96. //+
  97.  
  98. static struct Hook hook_drawback[]     = { NULL,NULL,(HOOKFUNC) drawback,     NULL,NULL };
  99. static struct Hook hook_drawcursor[]   = { NULL,NULL,(HOOKFUNC) drawcursor,   NULL,NULL };
  100. static struct Hook hook_drawcursor2[]  = { NULL,NULL,(HOOKFUNC) drawcursor2,  NULL,NULL };
  101. static struct Hook hook_drawblink[]    = { NULL,NULL,(HOOKFUNC) drawblink,    NULL,NULL };
  102. static        UBYTE __str[] = "Haplo is a lord";
  103. static        UBYTE __hex[] = "ABCDEFabcdef0123456789";
  104. static        UBYTE __num[] = "0123456789";
  105. static        UBYTE upstr[] = "<pens style=shadow>Yea baby !!";
  106.  
  107. #define String_(s,l)          F_MakeObj(FV_MakeObj_String,s,l)
  108. //+
  109.  
  110. ///Main
  111. void main(void)
  112. {
  113.    static char myback[16];
  114.    static char mycursor[16];
  115.    static char mycursor2[16];
  116.    static char myblink[16];
  117.    APTR        app,win,str,txt;
  118.  
  119.    if (FeelinBase = (APTR) OpenLibrary("feelin.library",FV_VERSION))
  120.    {
  121.       F_RawFormat(&myback,    "H:%08lx",&hook_drawback);
  122.       F_RawFormat(&mycursor,  "H:%08lx",&hook_drawcursor);
  123.       F_RawFormat(&mycursor2, "H:%08lx",&hook_drawcursor2);
  124.       F_RawFormat(&myblink,   "H:%08lx",&hook_drawblink);
  125.  
  126.       app = AppObject,
  127.          Child, win = WindowObject,
  128.             FA_Window_Title, "Feelin : Strings",
  129.             FA_Window_Open,   TRUE,
  130.  
  131.             Child, Page,
  132.                Child, VGroup, FA_Group_Title, "Examples",
  133.                   Child, VGroup, GroupFrame, FA_Frame_Title, "Numeric",
  134.                      Child, StringObject, "FA_String_MaxLen",32, "FA_String_Accept",__num, "FA_String_Integer", 1234, End,
  135.                   End,
  136.                   Child, VGroup, GroupFrame, FA_Frame_Title, "Hexadecimal",
  137.                      Child, StringObject, "FA_String_MaxLen",80, "FA_String_Accept",__hex, "FA_String_Contents", "12a4BC", End,
  138.                   End,
  139.                   Child, VGroup, GroupFrame, FA_Frame_Title, "Alphabetic",
  140.                      Child, StringObject, "FA_String_Contents",__str, "FA_String_MaxLen",80, "FA_String_Reject",__num, "FA_String_Format",FV_String_Left,   End,
  141.                      Child, StringObject, "FA_String_Contents",__str, "FA_String_MaxLen",80, "FA_String_Reject",__num, "FA_String_Format",FV_String_Center, End,
  142.                      Child, StringObject, "FA_String_Contents",__str, "FA_String_MaxLen",80, "FA_String_Reject",__num, "FA_String_Format",FV_String_Right,  End,
  143.                   End,
  144.                End,
  145.  
  146.                Child, VGroup,
  147.                   FA_SetMax,        FV_SetMaxH,
  148.                   FA_Group_Title,   "Custom",
  149.  
  150.                   Child, F_NewObj(FC_String,
  151.                      FA_Font,"Garnet/16",
  152.                      "FA_String_Contents",   __str,
  153.                      "FA_String_Format",     FV_String_Left,
  154.                      "FA_String_BlinkSpeed",   10,
  155.                      End,
  156.  
  157.                   Child, F_NewObj(FC_String,
  158.                      FA_Back,                   &myback,
  159.                      FA_Font,                   "Times/36",
  160.                      "FA_String_Contents",      __str,
  161.                      "FA_String_Format",        FV_String_Center,
  162.                      "FA_String_BlinkSpeed",    10,
  163.                      "FA_String_TextActive",    "c:0044DD",
  164.                      "FA_String_TextInactive",  "c:00277F",
  165.                      "FA_String_TextBlock",     "c:0066EE",
  166.                      "FA_String_Cursor",        &mycursor,
  167.                      "FA_String_Blink",         &myblink,
  168.                      End,
  169.  
  170.                   Child, F_NewObj(FC_String,
  171.                      FA_Back,       &myback,
  172.                      FA_Font,       "Diamond/20",
  173.                      "FA_String_Contents",   __str,
  174.                      "FA_String_Format",     FV_String_Right,
  175.                      "FA_String_Cursor",     &mycursor2,
  176.                      "FA_String_TextBlock",  "s:4",
  177.                      End,
  178.                End,
  179.  
  180.                Child, VGroup,
  181.                   FA_Group_Title, "Notification",
  182.  
  183.                   Child, TextObject, FA_SetMax,TRUE, DontChain, FA_Text_Shortcut,FALSE, FA_Text,"<align=justify><pens style=shadow>All modifications done in the<br>FC_String object below will be<br>reported to the FC_Text object.<hr>You can enter HTML formating<br>codes to adjust text.</pens><br>Try <pens style=ghost><stop><align=center></stop></pens> before your text.", End,
  184.                   Child, str = String_(upstr,256),
  185.                   Child, txt = TextObject, FA_Frame, "FP_Gauge_Frame", DontChain, FA_Inner_Left,3,FA_Inner_Top,2,FA_Inner_Right,3,FA_Inner_Bottom,2,FA_Font,"FP_Font_Big", FA_SetMax,FV_SetMaxH, FA_Text_Static,TRUE, /*FA_Text_PreParse,"`l`n`Sn`p0",*/ FA_Text,upstr, End,
  186.                End,
  187.             End,
  188.          End,
  189.       End;
  190.  
  191.       if (app)
  192.       {
  193.          F_Do(str,FM_Notify,F_DynamicFindID("FA_String_Contents"),FV_Notify_Always,txt,FM_Set,2,FA_Text,FV_Notify_Value);
  194.          F_Do(win,FM_Notify,FA_Window_CloseRequest,TRUE,app,FM_Application_Shutdown,0);
  195.          F_Do(app,FM_Application_Run);
  196.  
  197.          F_DisposeObj(app);
  198.       }
  199.  
  200.       CloseLibrary(FeelinBase);
  201.    }
  202.    else Printf("Unable to open feelin.library\n");
  203. }
  204. //+
  205.